home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_casm / snip9611.zip / STRCASE.C < prev    next >
C/C++ Source or Header  |  1996-11-24  |  4KB  |  90 lines

  1. /* +++Date last modified: 12-Nov-1996 */
  2.  
  3. /***************************************************************************
  4. * @(#)strcase
  5. * @(#)    Converts a string to upper/lowercase using non ASCII convertion
  6. *
  7. ***************************************************************************
  8. *@(#)1993 Erik Bachmann
  9. *
  10. * Released to public domain 27-Oct-95
  11. ***************************************************************************/
  12. #include <string.h>                            /* strlen */
  13. #include "bacstd.h"
  14.  
  15. /*
  16.  /-------------------------------------\
  17. |          STRCASE                      |------------------------------------|
  18. |\-------------------------------------/                                    
  19. |                                                                            
  20. | Converts a string to upper/lowercase using non ASCII convertion            
  21. |                                                                            
  22. | Examples of sort sequences found in SORTKEY.h                              
  23. |----------------------------------------------------------------------------|
  24. | CALL:                                                                      
  25. |    pszStr = strcase("abcæ¢å", (unsigned char *) CaseUpper) ;                
  26. |                                                                            
  27. | HEADER:                                                                    
  28. |    sortkey.h                                                               
  29. |                                                                            
  30. | GLOBALE VARIABLES:                                                         
  31. |    %                                                                       
  32. |                                                                            
  33. | ARGUMENTS:                                                                 
  34. |    char *pszStr       Pointer to string                                    
  35. |    char *pszOrder     Pointer to table with sort sequences                 
  36. |                                                                            
  37. | PROTOTYPE:                                                                 
  38. |    int _CfmTYPE strcase(unsigned char *pszStr, unsigned char *pszOrder) ;   
  39. |                                                                            
  40. | RETURN VALUE:                                                              
  41. |    char *        Pointer to string                                         
  42. |                                                                            
  43. | MODULE:                                                                    
  44. |    STRCASE.c                                                               
  45. |----------------------------------------------------------------------------|
  46. |                                                                            
  47. |----------------------------------------------------------------------------|
  48. |1993-04-10/Erik Bachmann                                                    
  49. \---------------------------------------------------------------------------|*/
  50.  
  51. unsigned char _CfnTYPE *strcase(unsigned char *pszStr, unsigned char *pszOrder)
  52. {
  53.     long         lCount    =    0L ;
  54.  
  55.     /*---------------------------------------------------------*/
  56.  
  57.     for ( lCount = 0L ; '\0' != pszStr[lCount] ; lCount++ )
  58.     {
  59.         pszStr[lCount] = pszOrder[ pszStr[lCount] ] ;
  60.     }
  61.  
  62.     return( pszStr ) ;
  63. }    /*** strcase() ***/
  64.  
  65. #ifdef    TEST
  66.  
  67. #include "sortkey.h"
  68.  
  69. int    main()
  70. {
  71.     int i;
  72.     char                *str    = "abcdæ¢åäöäöé";
  73.  
  74.     /*---------------------------------------*/
  75.  
  76.     fprintf(stderr, "strcase()\n\n");
  77.  
  78.     printf("\nOriginal string : %s", str);
  79.  
  80.     strcase(str, (unsigned char *) CaseUpper);
  81.     printf("\nUppercase string: %s", str);
  82.  
  83.     strcase(str, (unsigned char *) CaseLower);
  84.     printf("\nLowercase string: %s", str);
  85.  
  86.     return( 0 ) ;
  87. }    /*** main() ***/
  88.  
  89. #endif
  90.